﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Employees.aspx.cs" Inherits="Baitap3.Employees" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

<!-- hé lu, BB is here -->

</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="PageHeading" runat="server">
<h1>Employees Page</h1>
<br />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div style="margin-left: 26px">
    <div class="datalist">
    <asp:DataList ID="DataList2" CssClass="datalist" runat="server" DataKeyField="EmployeeID" 
        DataSourceID="SqlDataSource2" ondeletecommand="DataList2_DeleteCommand" >
        <ItemTemplate>
        <div class="personal-photo">
            <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("URLPersonalPhoto") %>' />
        </div>
        <div class="personal-info">
            EmployeeID:
            <asp:Label ID="EmployeeIDLabel" cssClass="bold" runat="server" 
                Text='<%# Eval("EmployeeID") %>' />
            <br />
            LastName:
            <asp:Label ID="LastNameLabel" cssClass="bold" runat="server" Text='<%# Eval("LastName") %>' />
            <br />
            FirstName:
            <asp:Label ID="FirstNameLabel" cssClass="bold" runat="server" Text='<%# Eval("FirstName") %>' />
            <br />
            DepartmentID:
            <asp:Label ID="DepartmentIDLabel" cssClass="bold" runat="server" 
                Text='<%# Eval("DepartmentID") %>' />
            <br />
            <div class="buttons">
            <asp:LinkButton ID="LinkButton2" runat="server" CommandName="select" >View Detail</asp:LinkButton>
            &nbsp;-&nbsp;
            <asp:LinkButton ID="LinkDeleteButton2" runat="server" CausesValidation="False" 
                CommandName="Delete" Text="Delete" />
                </div>
            </div>
        </ItemTemplate>
    </asp:DataList>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PagingDataConnectionString %>" 
        
        SelectCommand="SELECT Departments.Name, Employees.* FROM Employees INNER JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID WHERE (Departments.DepartmentID = @DepartmentID) AND (Departments.ShowControl = @ShowControl)" 
        DeleteCommand="DELETE FROM [Employees] WHERE [EmployeeID] = @EmployeeID" 
        InsertCommand="INSERT INTO [Employees] ([LastName], [FirstName], [DepartmentID], [Salary], [HireDate], [URLPersonalPhoto], [Description]) VALUES (@LastName, @FirstName, @DepartmentID, @Salary, @HireDate, @URLPersonalPhoto, @Description)" 
        UpdateCommand="UPDATE [Employees] SET [LastName] = @LastName, [FirstName] = @FirstName, [DepartmentID] = @DepartmentID, [Salary] = @Salary, [HireDate] = @HireDate, [URLPersonalPhoto] = @URLPersonalPhoto, [Description] = @Description WHERE [EmployeeID] = @EmployeeID">
        <DeleteParameters>
            <asp:Parameter Name="EmployeeID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="LastName" Type="String" />
            <asp:Parameter Name="FirstName" Type="String" />
            <asp:Parameter Name="DepartmentID" Type="Int32" />
            <asp:Parameter Name="Salary" Type="Decimal" />
            <asp:Parameter Name="HireDate" Type="DateTime" />
            <asp:Parameter Name="URLPersonalPhoto" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="FloatBox$DataList1" Name="DepartmentID" 
                PropertyName="SelectedValue" />
            <asp:Parameter DefaultValue="Datalist" Name="ShowControl" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="LastName" Type="String" />
            <asp:Parameter Name="FirstName" Type="String" />
            <asp:Parameter Name="DepartmentID" Type="Int32" />
            <asp:Parameter Name="Salary" Type="Decimal" />
            <asp:Parameter Name="HireDate" Type="DateTime" />
            <asp:Parameter Name="URLPersonalPhoto" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="EmployeeID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
        <%-- Datalist view,  insert, delete form --%>
    <asp:FormView ID="FormView2" CssClass="more-detail" runat="server" DataKeyNames="EmployeeID" 
        DataSourceID="DatalistFormSource" EnableModelValidation="True"
        OnItemDeleted="FormView2_ItemDeleted"
        OnItemInserted="FormView2_ItemInserted" 
        OnItemUpdated="FormView2_ItemUpdated">
        <EditItemTemplate>
        <h2>Employee Information</h2>
        <div class="personal-photo">
            <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("URLPersonalPhoto") %>' />
        </div>
        <div class="personal-info">
            EmployeeID:
            <asp:Label ID="EmployeeIDLabel1" runat="server" 
                Text='<%# Eval("EmployeeID") %>' />
            <br />
            LastName:
            <asp:TextBox ID="LastNameTextBox" runat="server" 
                Text='<%# Bind("LastName") %>' />
            <br />
            FirstName:
            <asp:TextBox ID="FirstNameTextBox" runat="server" 
                Text='<%# Bind("FirstName") %>' />
            <br />
            DepartmentID:
            <asp:TextBox ID="DepartmentIDTextBox" runat="server" 
                Text='<%# Bind("DepartmentID") %>' />
            <br />
            Salary:
            <asp:TextBox ID="SalaryTextBox" runat="server" Text='<%# Bind("Salary") %>' />
            <br />
            HireDate:
            <asp:TextBox ID="HireDateTextBox" runat="server" 
                Text='<%# Bind("HireDate") %>' />
            <br />
            URLPersonalPhoto:
            <asp:TextBox ID="URLPersonalPhotoTextBox" runat="server" 
                Text='<%# Bind("URLPersonalPhoto") %>' />
            <br />
            Description:
            <asp:TextBox ID="DescriptionTextBox" runat="server" 
                Text='<%# Bind("Description") %>' />
            <br />
            <div class="buttons" >
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                CommandName="Update" Text="Update" />
            &nbsp;-<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                </div>
        </div>
        </EditItemTemplate>
        <InsertItemTemplate>
        <h2>Employee Information</h2>
            <div class="personal-photo">
            <asp:Image ID="Image1" runat="server" ImageUrl="image/emp.jpg" />
        </div>
        <div class="personal-info">
            LastName:
            <asp:TextBox ID="LastNameTextBox" runat="server" 
                Text='<%# Bind("LastName") %>' />
            <br />
            FirstName:
            <asp:TextBox ID="FirstNameTextBox" runat="server" 
                Text='<%# Bind("FirstName") %>' />
            <br />
            DepartmentID:
            <asp:TextBox ID="DepartmentIDTextBox" runat="server" 
                Text='<%# Bind("DepartmentID") %>' />
            <br />
            Salary:
            <asp:TextBox ID="SalaryTextBox" runat="server" Text='<%# Bind("Salary") %>' />
            <br />
            HireDate:
            <asp:TextBox ID="HireDateTextBox" runat="server" 
                Text='<%# Bind("HireDate") %>' />
            <br />
            URLPersonalPhoto:
            <asp:TextBox ID="URLPersonalPhotoTextBox" runat="server" 
                Text='<%# Bind("URLPersonalPhoto") %>' />
            <br />
            Description:
            <asp:TextBox ID="DescriptionTextBox" runat="server" 
                Text='<%# Bind("Description") %>' />
            <br />
            <div class="buttons" >
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                CommandName="Insert" Text="Insert" />&nbsp;-
            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                </div>
                </div>
        </InsertItemTemplate>
        <ItemTemplate>
        <h2>Employee Information</h2>
            <div class="personal-photo">
            <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("URLPersonalPhoto") %>' />
        </div>
        <div class="personal-info">
            EmployeeID:
            <asp:Label ID="EmployeeIDLabel" CssClass="bold" runat="server" 
                Text='<%# Eval("EmployeeID") %>' />
            <br />
            LastName:
            <asp:Label ID="LastNameLabel" CssClass="bold" runat="server" Text='<%# Eval("LastName") %>' />
            <br />
            FirstName:
            <asp:Label ID="FirstNameLabel" CssClass="bold" runat="server" Text='<%# Eval("FirstName") %>' />
            <br />
            DepartmentID:
            <asp:Label ID="DepartmentIDLabel" CssClass="bold" runat="server" 
                Text='<%# Eval("DepartmentID") %>' />
            <br />
            Salary:
            <asp:Label ID="SalaryLabel" CssClass="bold" runat="server" Text='<%# Eval("Salary") %>' />
            <br />
            HireDate:
            <asp:Label ID="HireDateLabel" CssClass="bold" runat="server" Text='<%# Eval("HireDate") %>' />
            <br />
            URLPersonalPhoto:
            <asp:Label ID="URLPersonalPhotoLabel" CssClass="bold" runat="server" 
                Text='<%# Eval("URLPersonalPhoto") %>' />
            <br />
            Description:
            <asp:Label ID="DescriptionLabel" CssClass="bold" runat="server" 
                Text='<%# Eval("Description") %>' />
            <br />
            <div class="buttons" >
            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                CommandName="Edit" Text="Edit" />&nbsp;-
            <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                CommandName="Delete" Text="Delete" />&nbsp;-
            <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="New" />
            </div>
            </div>
            
        </ItemTemplate>
    </asp:FormView>
    <asp:SqlDataSource ID="DatalistFormSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PagingDataConnectionString %>" 
        
            
            SelectCommand="SELECT * FROM [Employees] WHERE (([DepartmentID] = @DepartmentID) AND ([EmployeeID] = @EmployeeID))" 
            DeleteCommand="DELETE FROM [Employees] WHERE [EmployeeID] = @EmployeeID" 
            InsertCommand="INSERT INTO [Employees] ([LastName], [FirstName], [DepartmentID], [Salary], [HireDate], [URLPersonalPhoto], [Description]) VALUES (@LastName, @FirstName, @DepartmentID, @Salary, @HireDate, @URLPersonalPhoto, @Description)" 
            UpdateCommand="UPDATE [Employees] SET [LastName] = @LastName, [FirstName] = @FirstName, [DepartmentID] = @DepartmentID, [Salary] = @Salary, [HireDate] = @HireDate, [URLPersonalPhoto] = @URLPersonalPhoto, [Description] = @Description WHERE [EmployeeID] = @EmployeeID">
        <DeleteParameters>
            <asp:Parameter Name="EmployeeID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="LastName" Type="String" />
            <asp:Parameter Name="FirstName" Type="String" />
            <asp:Parameter Name="DepartmentID" Type="Int32" />
            <asp:Parameter Name="Salary" Type="Decimal" />
            <asp:Parameter Name="HireDate" Type="DateTime" />
            <asp:Parameter Name="URLPersonalPhoto" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="FloatBox$DataList1" Name="DepartmentID" 
                PropertyName="SelectedValue" Type="Int32" />
            <asp:ControlParameter ControlID="DataList2" Name="EmployeeID" 
                PropertyName="SelectedValue" Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="LastName" Type="String" />
            <asp:Parameter Name="FirstName" Type="String" />
            <asp:Parameter Name="DepartmentID" Type="Int32" />
            <asp:Parameter Name="Salary" Type="Decimal" />
            <asp:Parameter Name="HireDate" Type="DateTime" />
            <asp:Parameter Name="URLPersonalPhoto" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="EmployeeID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <%-- End of Datalist form --%>
    </div>

    <%-- Gridview --%>
    <%-- Form using for insert data to DataGridView --%>
    <asp:FormView ID="FormView1" runat="server" DataKeyNames="EmployeeID" 
        DataSourceID="GridDataSource" EnableModelValidation="True" >
        <EditItemTemplate>
            LastName:
            <asp:TextBox ID="LastNameTextBox" runat="server" 
                Text='<%# Bind("LastName") %>' />
            <br />
            FirstName:
            <asp:TextBox ID="FirstNameTextBox" runat="server" 
                Text='<%# Bind("FirstName") %>' />
            <br />
            HireDate:
            <asp:TextBox ID="HireDateTextBox" runat="server" 
                Text='<%# Bind("HireDate") %>' />
            <br />
            Salary:
            <asp:TextBox ID="SalaryTextBox" runat="server" Text='<%# Bind("Salary") %>' />
            <br />
            EmployeeID:
            <asp:Label ID="EmployeeIDLabel1" runat="server" 
                Text='<%# Eval("EmployeeID") %>' />
            <br />
            URLPersonalPhoto:
            <asp:TextBox ID="URLPersonalPhotoTextBox" runat="server" 
                Text='<%# Bind("URLPersonalPhoto") %>' />
            <br />
            DepartmentID:
            <asp:TextBox ID="DepartmentIDTextBox" runat="server" 
                Text='<%# Bind("DepartmentID") %>' />
            <br />
            Description:
            <asp:TextBox ID="DescriptionTextBox" runat="server" 
                Text='<%# Bind("Description") %>' />
            <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                CommandName="Update" Text="Update" />
            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </EditItemTemplate>
        <InsertItemTemplate>
        <div class="grid-insert">
        <h2>New Employee:</h2>
            LastName:
            <asp:TextBox ID="LastNameTextBox" runat="server" 
                Text='<%# Bind("LastName") %>' />
            <br />
            FirstName:
            <asp:TextBox ID="FirstNameTextBox" runat="server" 
                Text='<%# Bind("FirstName") %>' />
            <br />
            HireDate:
            <asp:TextBox ID="HireDateTextBox" runat="server" 
                Text='<%# Bind("HireDate") %>' />
            <br />
            Salary:
            <asp:TextBox ID="SalaryTextBox" runat="server" Text='<%# Bind("Salary") %>' />
            <br />

            URLPersonalPhoto:
            <asp:TextBox ID="URLPersonalPhotoTextBox" runat="server" 
                Text='<%# Bind("URLPersonalPhoto") %>' />
            <br />
            DepartmentID:
            <asp:TextBox ID="DepartmentIDTextBox" runat="server" 
                Text='<%# Bind("DepartmentID") %>' />
            <br />
            Description:
            <asp:TextBox ID="DescriptionTextBox" runat="server" 
                Text='<%# Bind("Description") %>' />
            <br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                CommandName="Insert" Text="Insert" />
            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                </div>
        </InsertItemTemplate>
        <ItemTemplate>
            &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="New Employee" />
        </ItemTemplate>
    </asp:FormView>
    <%-- End of Datagridview insert form --%>
    <div class="gridview">
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" DataSourceID="GridDataSource" 
        EnableModelValidation="True" DataKeyNames="EmployeeID">
        <Columns>
            <asp:ImageField DataImageUrlField="URLPersonalPhoto" HeaderText="Image">
            </asp:ImageField>
            <asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID" 
                SortExpression="EmployeeID" InsertVisible="False" ReadOnly="True" />
            <asp:BoundField DataField="LastName" HeaderText="Last Name" 
                SortExpression="LastName" />
            <asp:BoundField DataField="FirstName" HeaderText="First Name" 
                SortExpression="FirstName" />
            <asp:BoundField DataField="DepartmentID" HeaderText="DepartmentID" 
                SortExpression="DepartmentID" />
            <asp:BoundField DataField="Salary" HeaderText="Salary" 
                SortExpression="Salary" />
            <asp:BoundField DataField="HireDate" HeaderText="Hire Date" 
                SortExpression="HireDate" />
            <asp:BoundField DataField="Description" HeaderText="Description" 
                SortExpression="Description" />
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="GridDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PagingDataConnectionString %>" 
 
        
        SelectCommand="SELECT Employees.LastName, Employees.FirstName, Employees.HireDate, Employees.Salary, Employees.EmployeeID, Employees.URLPersonalPhoto, Employees.DepartmentID, Employees.Description FROM Employees INNER JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID WHERE (Departments.DepartmentID = @DepartmentID) AND (Departments.ShowControl = @ShowControl)" 
        DeleteCommand="DELETE FROM [Employees] WHERE [EmployeeID] = @EmployeeID" 
        InsertCommand="INSERT INTO [Employees] ([LastName], [FirstName], [DepartmentID], [Salary], [HireDate], [URLPersonalPhoto], [Description]) VALUES (@LastName, @FirstName, @DepartmentID, @Salary, @HireDate, @URLPersonalPhoto, @Description)" 
        UpdateCommand="UPDATE [Employees] SET [LastName] = @LastName, [FirstName] = @FirstName, [DepartmentID] = @DepartmentID, [Salary] = @Salary, [HireDate] = @HireDate, [URLPersonalPhoto] = @URLPersonalPhoto, [Description] = @Description WHERE [EmployeeID] = @EmployeeID">
        <DeleteParameters>
            <asp:Parameter Name="EmployeeID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="LastName" Type="String" />
            <asp:Parameter Name="FirstName" Type="String" />
            <asp:Parameter Name="DepartmentID" Type="Int32" />
            <asp:Parameter Name="Salary" Type="Decimal" />
            <asp:Parameter Name="HireDate" Type="DateTime" />
            <asp:Parameter Name="URLPersonalPhoto" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="FloatBox$DataList1" Name="DepartmentID" 
                PropertyName="SelectedValue" />
            <asp:Parameter DefaultValue="Gridview" Name="ShowControl" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="LastName" Type="String" />
            <asp:Parameter Name="FirstName" Type="String" />
            <asp:Parameter Name="DepartmentID" Type="Int32" />
            <asp:Parameter Name="Salary" Type="Decimal" />
            <asp:Parameter Name="HireDate" Type="DateTime" />
            <asp:Parameter Name="URLPersonalPhoto" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="EmployeeID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    </div>
    <asp:DetailsView ID="DetailsView1" runat="server"
        AllowPaging="True" AutoGenerateRows="False" DataSourceID="DetailDataSource" 
        EnableModelValidation="True" DataKeyNames="EmployeeID">
        <Fields>
            <asp:ImageField DataImageUrlField="URLPersonalPhoto" HeaderText="Image">
            </asp:ImageField>
            <asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID" 
                SortExpression="EmployeeID" InsertVisible="False" ReadOnly="True" />
            <asp:BoundField DataField="LastName" HeaderText="LastName" 
                SortExpression="LastName" />
            <asp:BoundField DataField="FirstName" HeaderText="FirstName" 
                SortExpression="FirstName" />
            <asp:BoundField DataField="DepartmentID" HeaderText="DepartmentID" 
                SortExpression="DepartmentID" />
            <asp:BoundField DataField="Salary" HeaderText="Salary" 
                SortExpression="Salary" />
            <asp:BoundField DataField="HireDate" HeaderText="HireDate" 
                SortExpression="HireDate" />
            <asp:BoundField DataField="Description" HeaderText="Description" 
                SortExpression="Description" />
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                ShowInsertButton="True" />
        </Fields>
        <HeaderTemplate>
            DetailView
        </HeaderTemplate>
    </asp:DetailsView>
    <asp:SqlDataSource ID="DetailDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PagingDataConnectionString %>" 
        
        SelectCommand="SELECT Employees.* FROM Employees INNER JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID WHERE (Departments.DepartmentID = @DepartmentID) AND (Departments.ShowControl = @ShowControl)" 
        DeleteCommand="DELETE FROM [Employees] WHERE [EmployeeID] = @EmployeeID" 
        InsertCommand="INSERT INTO [Employees] ([LastName], [FirstName], [DepartmentID], [Salary], [HireDate], [URLPersonalPhoto], [Description]) VALUES (@LastName, @FirstName, @DepartmentID, @Salary, @HireDate, @URLPersonalPhoto, @Description)" 
        UpdateCommand="UPDATE [Employees] SET [LastName] = @LastName, [FirstName] = @FirstName, [DepartmentID] = @DepartmentID, [Salary] = @Salary, [HireDate] = @HireDate, [URLPersonalPhoto] = @URLPersonalPhoto, [Description] = @Description WHERE [EmployeeID] = @EmployeeID">
        <DeleteParameters>
            <asp:Parameter Name="EmployeeID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="LastName" Type="String" />
            <asp:Parameter Name="FirstName" Type="String" />
            <asp:Parameter Name="DepartmentID" Type="Int32" />
            <asp:Parameter Name="Salary" Type="Decimal" />
            <asp:Parameter Name="HireDate" Type="DateTime" />
            <asp:Parameter Name="URLPersonalPhoto" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="FloatBox$DataList1" Name="DepartmentID" 
                PropertyName="SelectedValue" />
            <asp:Parameter DefaultValue="Detailview" Name="ShowControl" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="LastName" Type="String" />
            <asp:Parameter Name="FirstName" Type="String" />
            <asp:Parameter Name="DepartmentID" Type="Int32" />
            <asp:Parameter Name="Salary" Type="Decimal" />
            <asp:Parameter Name="HireDate" Type="DateTime" />
            <asp:Parameter Name="URLPersonalPhoto" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="EmployeeID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>


    <div class="repeater">
    <asp:Repeater ID="Repeater1" runat="server"  DataSourceID="RepeaterDataSource" 
             OnItemCommand="Repeater1_ItemCommand" >
    <HeaderTemplate>
    <table class="datalist" style="border-collapse:collapse;">
    </HeaderTemplate>
    <ItemTemplate>
    <tr>
    <td>
        <div class="personal-photo">
            <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("URLPersonalPhoto") %>' />
        </div>
        <div class="personal-info">
            EmployeeID:
            <asp:Label ID="EmployeeIDLabel" cssClass="bold" runat="server" 
                Text='<%# Eval("EmployeeID") %>' />
            <br />
            LastName:
            <asp:Label ID="LastNameLabel" cssClass="bold" runat="server" Text='<%# Eval("LastName") %>' />
            <br />
            FirstName:
            <asp:Label ID="FirstNameLabel" cssClass="bold" runat="server" Text='<%# Eval("FirstName") %>' />
            <br />
            DepartmentID:
            <asp:Label ID="DepartmentIDLabel" cssClass="bold" runat="server" 
                Text='<%# Eval("DepartmentID") %>' />
            <br />
            <div class="buttons">
            <asp:LinkButton ID="rpt_View" runat="server" CommandName="ViewDetail" CommandArgument='<%# Eval("EmployeeID") %>' >View Detail</asp:LinkButton>
            &nbsp;-&nbsp;
            <asp:LinkButton ID="LinkDeleteButton2" runat="server" CausesValidation="False" 
                CommandName="Delete" CommandArgument='<%# Eval("EmployeeID") %>' Text="Delete" />
                </div>
            </div>
            </td>
            </tr>
        </ItemTemplate>
        <FooterTemplate>
        </table>
        </FooterTemplate>
</asp:Repeater>
    <asp:SqlDataSource ID="RepeaterDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PagingDataConnectionString %>" 
        
        SelectCommand="SELECT Employees.* FROM Employees INNER JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID WHERE (Departments.DepartmentID = @DepartmentID) AND (Departments.ShowControl = @ShowControl)" 
        DeleteCommand="DELETE FROM [Employees] WHERE [EmployeeID] = @EmployeeID" 
        InsertCommand="INSERT INTO [Employees] ([LastName], [FirstName], [DepartmentID], [Salary], [HireDate], [URLPersonalPhoto], [Description]) VALUES (@LastName, @FirstName, @DepartmentID, @Salary, @HireDate, @URLPersonalPhoto, @Description)" 
        UpdateCommand="UPDATE [Employees] SET [LastName] = @LastName, [FirstName] = @FirstName, [DepartmentID] = @DepartmentID, [Salary] = @Salary, [HireDate] = @HireDate, [URLPersonalPhoto] = @URLPersonalPhoto, [Description] = @Description WHERE [EmployeeID] = @EmployeeID">
        <DeleteParameters>
            <asp:Parameter Name="EmployeeID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="LastName" Type="String" />
            <asp:Parameter Name="FirstName" Type="String" />
            <asp:Parameter Name="DepartmentID" Type="Int32" />
            <asp:Parameter Name="Salary" Type="Decimal" />
            <asp:Parameter Name="HireDate" Type="DateTime" />
            <asp:Parameter Name="URLPersonalPhoto" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="FloatBox$DataList1" Name="DepartmentID" 
                PropertyName="SelectedValue" />
            <asp:Parameter DefaultValue="Repeater" Name="ShowControl" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="LastName" Type="String" />
            <asp:Parameter Name="FirstName" Type="String" />
            <asp:Parameter Name="DepartmentID" Type="Int32" />
            <asp:Parameter Name="Salary" Type="Decimal" />
            <asp:Parameter Name="HireDate" Type="DateTime" />
            <asp:Parameter Name="URLPersonalPhoto" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="EmployeeID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
        <asp:FormView ID="FormView3" CssClass="more-detail" runat="server" DataKeyNames="EmployeeID" 
            DataSourceID="RepeaterFormDataSource" EnableModelValidation="True"
            OnItemDeleted="FormView3_ItemDeleted"
            OnItemInserted="FormView3_ItemInserted" 
            OnItemUpdated="FormView3_ItemUpdated" >
            <EditItemTemplate>
        <h2>Employee Information</h2>
        <div class="personal-photo">
            <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("URLPersonalPhoto") %>' />
        </div>
        <div class="personal-info">
            EmployeeID:
            <asp:Label ID="EmployeeIDLabel1" runat="server" 
                Text='<%# Eval("EmployeeID") %>' />
            <br />
            LastName:
            <asp:TextBox ID="LastNameTextBox" runat="server" 
                Text='<%# Bind("LastName") %>' />
            <br />
            FirstName:
            <asp:TextBox ID="FirstNameTextBox" runat="server" 
                Text='<%# Bind("FirstName") %>' />
            <br />
            DepartmentID:
            <asp:TextBox ID="DepartmentIDTextBox" runat="server" 
                Text='<%# Bind("DepartmentID") %>' />
            <br />
            Salary:
            <asp:TextBox ID="SalaryTextBox" runat="server" Text='<%# Bind("Salary") %>' />
            <br />
            HireDate:
            <asp:TextBox ID="HireDateTextBox" runat="server" 
                Text='<%# Bind("HireDate") %>' />
            <br />
            URLPersonalPhoto:
            <asp:TextBox ID="URLPersonalPhotoTextBox" runat="server" 
                Text='<%# Bind("URLPersonalPhoto") %>' />
            <br />
            Description:
            <asp:TextBox ID="DescriptionTextBox" runat="server" 
                Text='<%# Bind("Description") %>' />
            <br />
            <div class="buttons" >
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                CommandName="Update" Text="Update" />
            &nbsp;-&nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                </div>
        </div>
        </EditItemTemplate>
        <InsertItemTemplate>
        <h2>Employee Information</h2>
            <div class="personal-photo">
            <asp:Image ID="Image1" runat="server" ImageUrl="image/emp.jpg" />
        </div>
        <div class="personal-info">
            LastName:
            <asp:TextBox ID="LastNameTextBox" runat="server" 
                Text='<%# Bind("LastName") %>' />
            <br />
            FirstName:
            <asp:TextBox ID="FirstNameTextBox" runat="server" 
                Text='<%# Bind("FirstName") %>' />
            <br />
            DepartmentID:
            <asp:TextBox ID="DepartmentIDTextBox" runat="server" 
                Text='<%# Bind("DepartmentID") %>' />
            <br />
            Salary:
            <asp:TextBox ID="SalaryTextBox" runat="server" Text='<%# Bind("Salary") %>' />
            <br />
            HireDate:
            <asp:TextBox ID="HireDateTextBox" runat="server" 
                Text='<%# Bind("HireDate") %>' />
            <br />
            URLPersonalPhoto:
            <asp:TextBox ID="URLPersonalPhotoTextBox" runat="server" 
                Text='<%# Bind("URLPersonalPhoto") %>' />
            <br />
            Description:
            <asp:TextBox ID="DescriptionTextBox" runat="server" 
                Text='<%# Bind("Description") %>' />
            <br />
            <div class="buttons" >
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                CommandName="Insert" Text="Insert" />&nbsp;-
            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                </div>
                </div>
        </InsertItemTemplate>
        <ItemTemplate>
        <h2>Employee Information</h2>
            <div class="personal-photo">
            <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("URLPersonalPhoto") %>' />
        </div>
        <div class="personal-info">
            EmployeeID:
            <asp:Label ID="EmployeeIDLabel" CssClass="bold" runat="server" 
                Text='<%# Eval("EmployeeID") %>' />
            <br />
            LastName:
            <asp:Label ID="LastNameLabel" CssClass="bold" runat="server" Text='<%# Eval("LastName") %>' />
            <br />
            FirstName:
            <asp:Label ID="FirstNameLabel" CssClass="bold" runat="server" Text='<%# Eval("FirstName") %>' />
            <br />
            DepartmentID:
            <asp:Label ID="DepartmentIDLabel" CssClass="bold" runat="server" 
                Text='<%# Eval("DepartmentID") %>' />
            <br />
            Salary:
            <asp:Label ID="SalaryLabel" CssClass="bold" runat="server" Text='<%# Eval("Salary") %>' />
            <br />
            HireDate:
            <asp:Label ID="HireDateLabel" CssClass="bold" runat="server" Text='<%# Eval("HireDate") %>' />
            <br />
            URLPersonalPhoto:
            <asp:Label ID="URLPersonalPhotoLabel" CssClass="bold" runat="server" 
                Text='<%# Eval("URLPersonalPhoto") %>' />
            <br />
            Description:
            <asp:Label ID="DescriptionLabel" CssClass="bold" runat="server" 
                Text='<%# Eval("Description") %>' />
            <br />
            <div class="buttons" >
            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                CommandName="Edit" Text="Edit" />&nbsp;-
            <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                CommandName="Delete" Text="Delete" />&nbsp;-
            <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="New" />
            </div>
            </div>
            
        </ItemTemplate>
        </asp:FormView>
        <asp:SqlDataSource ID="RepeaterFormDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:PagingDataConnectionString %>" 
            
            SelectCommand="SELECT * FROM [Employees] WHERE (([DepartmentID] = @DepartmentID) AND ([EmployeeID] = @EmployeeID))" 
            DeleteCommand="DELETE FROM [Employees] WHERE [EmployeeID] = @EmployeeID" 
            InsertCommand="INSERT INTO [Employees] ([LastName], [FirstName], [DepartmentID], [Salary], [HireDate], [URLPersonalPhoto], [Description]) VALUES (@LastName, @FirstName, @DepartmentID, @Salary, @HireDate, @URLPersonalPhoto, @Description)" 
            UpdateCommand="UPDATE [Employees] SET [LastName] = @LastName, [FirstName] = @FirstName, [DepartmentID] = @DepartmentID, [Salary] = @Salary, [HireDate] = @HireDate, [URLPersonalPhoto] = @URLPersonalPhoto, [Description] = @Description WHERE [EmployeeID] = @EmployeeID">
            <DeleteParameters>
                <asp:Parameter Name="EmployeeID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="LastName" Type="String" />
                <asp:Parameter Name="FirstName" Type="String" />
                <asp:Parameter Name="DepartmentID" Type="Int32" />
                <asp:Parameter Name="Salary" Type="Decimal" />
                <asp:Parameter Name="HireDate" Type="DateTime" />
                <asp:Parameter Name="URLPersonalPhoto" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
            </InsertParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="FloatBox$DataList1" Name="DepartmentID" 
                    PropertyName="SelectedValue" Type="Int32" />
                <asp:SessionParameter DefaultValue="" Name="EmployeeID" 
                    SessionField="RepeaterEmpID" Type="Int32" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="LastName" Type="String" />
                <asp:Parameter Name="FirstName" Type="String" />
                <asp:Parameter Name="DepartmentID" Type="Int32" />
                <asp:Parameter Name="Salary" Type="Decimal" />
                <asp:Parameter Name="HireDate" Type="DateTime" />
                <asp:Parameter Name="URLPersonalPhoto" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="EmployeeID" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
    </div>
    </div>
</asp:Content>


<asp:Content ID="Content3" ContentPlaceHolderID="FloatBox" runat="server">
    <div id="related-activities">
		<div id="related-act-top"><img src="images/department_box.png" width="271" height="43" alt="" /></div>		
		    <div id="related-act-bottom">		
			    <div id="related-act-inner">
                    <asp:DataList ID="DataList1" runat="server" DataKeyField="DepartmentID" DataSourceID="SqlDataSource1" 
                        SelectedItemStyle-ForeColor="#808080" Width="147px">
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" CommandName="select" runat="server" CssClass="box_item"><%# Eval("Name") %></asp:LinkButton>
                        </ItemTemplate>
                    </asp:DataList>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:PagingDataConnectionString %>" 
                        SelectCommand="SELECT [DepartmentID], [ShowControl], [Name] FROM [Departments]">
                    </asp:SqlDataSource>				
			    </div>	
			    <div class="clear"></div>
            </div>
	    </div>
</asp:Content>

